<template>
  <div class="login_layout">

    <div class="login_content">
      <div class="logo_title">
        <img src="@/assets/logo2.jpg" />
        翠微旅居云平台
      </div>
      <div class="login">
        <span class="login_title">用  户  登  录</span>
        <el-input class="login_input" :prefix-icon="User" v-model="name" size="large" clearable />
        <el-input class="login_input" :prefix-icon="Lock" v-model="password" type="password" size="large" clearable />
        <div class="login_but" @click="login()">登 录</div>
      </div>
    </div>

    <!-- <img class="login_illustration" src="@/assets/login_illustration.png" alt=""> -->
  </div>

</template>
<script setup>
import { ref, watch } from "vue";
import accout from "@api/accout";
import event from "@util/eventBus";
import auth from "@net/auth";
import { User, Lock } from "@element-plus/icons-vue";

let defaultName = null
let defaultPassword = null
if (process.env.NODE_ENV === "development") {
  defaultName = "admin"
  defaultPassword = "123456"
}

const name = ref(defaultName);
const password = ref(defaultPassword);

function login() {
  accout.login(name.value, password.value, (val) => {
    auth.setToken(val.accessToken);
    event.sendEvent("LOGIN");
    location.reload()
  });
}

</script>
<style lang="scss">
// * {
//   border: solid 1px black;
// }
.login_layout {
  width: 100vw;
  height: 100vh;
  background-image: url(@/assets/login_bg1.jpg);
  position: absolute;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  // background-image: linear-gradient(to top right, #160D51, #2F107C);
}

.login_title {
  font-size: 28px;
  margin-top: 10px;
  margin-bottom: 20px;
  text-align: center;
  color: #62bb6d;
}

.login_illustration {
  width: 600px;
  margin-left: 80px;
}

.login_content {
  // height: 70%;
  // width: 70%;
  height: 544px;
  width: 1024px;
  background-image: url(@/assets/login_bg2.png);
  background-size: 100%;
  background-repeat: no-repeat;
  background-position: center;
  position: relative;
}

.logo_title {
  font-weight: 500;
  font-size: 34px;
  color: #f8f8f8;
  position: absolute;
  top: 80px;
  left: 120px;
  display: flex;
  align-items: center;
}

.login {
  position: absolute;
  top: 60px;
  right: 100px;
  // margin-top: 40px;
  padding: 20px;
  height: 300px;
  width: 340px;
  border-radius: 15px;
  background-color: #fff;
  display: flex;
  flex-direction: column;

  .login_input {
    margin-top: 20px;
  }

  .login_but {
    cursor: pointer;
    height: 45px;
    width: 100%;
    // background-image: linear-gradient(to bottom right, #CD36F5, #E794F9);
    background-color: #62bb6d;
    color: #fff;
    margin-top: 40px;
    text-align: center;
    line-height: 45px;
    font-size: 16px;
    font-weight: bold;
    border-radius: 30px;
  }

}
</style>
